#include "widget.h"
#include "ui_widget.h"

#include <QTimer>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget),
    timer(new QTimer(this))
{
    ui->setupUi(this);
    connect(timer,&QTimer::timeout,this,&Widget::handle);
    ui->lcdNumber->display(10); //display("10") 也是可以的
    timer->start(1000);


}

Widget::~Widget()
{
    delete ui;
}

QLCDNumber *Widget::getlcdn()
{
    return ui->lcdNumber;
}

void Widget::handle()
{
    int value = ui->lcdNumber->intValue()-1;
    if(value < 0) {
        timer->stop();
        ui->lcdNumber->display("-----");
        return;
    }
    ui->lcdNumber->display(value);
}
